home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_10.lha / 7_10 / 7_10q.h < prev    next >
Text File  |  1993-08-08  |  2KB  |  87 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / modes for a process_queue
  6. num qmodes
  7.  
  8.    Q_WMODE,    // context switch when full/empty
  9.    Q_ZMODE,    // ignore objects when full/empty
  10.    Q_EMODE    // error when full/empty
  11. ;
  12. xtern char *qm_print(qmodes);        // DELETE
  13.  
  14. / queue manipulation
  15. lass process_queue
  16.  
  17. riend queue_head;
  18. riend queue_tail;
  19.  
  20.    queue_head *q_head;
  21.    queue_tail *q_tail;
  22.    process_object *q_last;
  23.    unsigned q_max;
  24.    unsigned q_count;
  25.  
  26.    process_queue(unsigned m, queue_head *qh, queue_tail *qt)
  27.    { q_max = m; q_count = 0; q_head = qh; q_tail = qt; }
  28.  
  29.    ~process_queue()
  30.    { if (q_count) error("delete queue with members"); }
  31. ;
  32.  
  33. lass queue_head : public process_object
  34.  
  35. riend queue_tail;
  36.    process_queue *qh_queue;
  37.  
  38. ublic:
  39.    qmodes qh_mode;
  40.  
  41.    queue_head(qmodes = Q_WMODE, unsigned = 10000);
  42.    ~queue_head();
  43.  
  44.    process_object *get();
  45.    int unget(process_object*);
  46.  
  47.    queue_tail *tail();
  48.  
  49.    queue_head *cut();
  50.    void splice(queue_tail*);
  51.  
  52.    // manipulate the maximum
  53.    unsigned rd_max() { return qh_queue->q_max; }
  54.    void set_max(unsigned m) { qh_queue->q_max = m; }
  55.  
  56.    unsigned rd_count() { return qh_queue->q_count; }
  57.    int pending();    // does queue_head have an object?
  58.         // T <== rd_count() == 0
  59. ;
  60.  
  61. lass queue_tail : public process_object
  62.  
  63. riend queue_head;
  64.    process_queue *qt_queue;
  65.  
  66. ublic:
  67.    qmodes qt_mode;
  68.  
  69.    queue_tail(qmodes = Q_WMODE, unsigned = 10000);
  70.    ~queue_tail();
  71.    int    put(process_object*);
  72.  
  73.    queue_head *head();
  74.  
  75.    queue_tail *cut();
  76.    void splice(queue_head*);
  77.  
  78.    // manipulate the maximum
  79.    unsigned rd_max()    { return qt_queue->q_max; }
  80.    void set_max(unsigned m)    { qt_queue->q_max = m; }
  81.  
  82.    unsigned rd_space()
  83.    { return qt_queue->q_max - qt_queue->q_count; }
  84.    int pending();    // does queue_tail have room?
  85.         // T <== rd_space() == 0
  86. ;
  87.